home *** CD-ROM | disk | FTP | other *** search
- // Copyright (c) 1999 Macromedia. All rights reserved.
-
- //Excute the script if there is a selection
- if (fw.selection != null && fw.selection.length > 0) {
- // Get the Document Size
- var docWidth = fw.getDocumentDOM().width;
- var docHeight = fw.getDocumentDOM().height;
- var docLeft = fw.getDocumentDOM().left;
- var docTop = fw.getDocumentDOM().top;
-
- // Figure out wwhere the middle of the Document is
- var middleWidth = docWidth/2;
- var middleHeight = docHeight/2;
-
- // Get the selection Size
- var selectBounds = fw.getDocumentDOM().getSelectionBounds();
- var selectLeft = selectBounds.left;
- var selectTop = selectBounds.top;
- var selectRight = selectBounds.right;
- var selectBottom = selectBounds.bottom;
-
- // Figure out where the middle of the selection is
- var selectMiddleWidth = (selectRight - selectLeft)/2;
- var selectMiddleHeight = (selectBottom - selectTop)/2;
-
- // Figure out where we need to move the selection to
- var moveToX = docLeft + middleWidth - selectMiddleWidth - selectLeft;
- var moveToY = docTop + middleHeight - selectMiddleHeight - selectTop;
-
- // Let's move it
- fw.getDocumentDOM().moveSelectionBy({x:moveToX, y:moveToY}, false, false);
- }
-
-
-